package type;

import java.util.Arrays;
import java.util.List;

/**
 * @Date 2021/4/29 11:03 上午
 * @Author dengxin
 */
public class TypeInfo {

    static abstract class Shape {
        void draw() {
            System.out.println(this.getName() + ".draw()");
        }

        abstract String getName();
    }

    static class Circle extends Shape {
        @Override
        String getName() {
            return "circle";
        }
    }

    static class Square extends Shape {
        @Override
        String getName() {
            return "square";
        }
    }

    static class Triangle extends Shape {
        @Override
        String getName() {
            return "triangle";
        }
    }

    public static void main(String[] args) {
//        List<Shape> shapeList = new ArrayList<>();
//        shapeList.add(new Circle());
//        shapeList.add(new Square());
//        shapeList.add(new Triangle());
        List<Shape> shapeList = Arrays.asList(new Circle(), new Square(), new Triangle());
        for (Shape shape: shapeList
             ) {
            shape.draw();
        }
    }
}
